//
//  DHComplicationsTableViewCell.m
//  DHKuaiYi
//
//  Created by  chenhanmao on 2016/11/15.
//  Copyright © 2016年 30-陈辉华. All rights reserved.
//

#import "DHComplicationsTableViewCell.h"
#import <Masonry.h>

@implementation DHComplicationsTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        [self setupUI];
    }
    return self;
}

- (void)setComplications:(DHComplicationsModel *)complications {
    
    _complications = complications;
    
    self.textLabel.text = complications.complication_name;
    
    UIButton *selectedBtn = (UIButton *)self.accessoryView;
    
    selectedBtn.selected = complications.isSelected;
}

#pragma mark - 自定义cell
- (void)setupUI {
    
    /*------------------分割线------------------*/
    UIView *separateLine = [[UIView alloc] init];
    
    separateLine.backgroundColor = [UIColor XHH_colorWithHex:0xefeff4];
    
    [self.contentView addSubview:separateLine];
    
    separateLine.frame = CGRectMake(0, 43, [UIScreen mainScreen].bounds.size.width, 1);
    
    /*------------------选中状态------------------*/
    
    // 创建右侧选中按钮
    UIButton *selectedBtn = [[UIButton alloc] init];
    [selectedBtn setImage:[UIImage imageNamed:@"select_default"] forState:UIControlStateNormal];
    [selectedBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [selectedBtn setImage:[UIImage imageNamed:@"select_click"] forState:UIControlStateSelected];
    selectedBtn.userInteractionEnabled = NO;

    [selectedBtn sizeToFit];
    
    self.accessoryView = selectedBtn;
//    CGFloat margin = 8;
//    [selectedBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        
//        make.centerY.equalTo(self.contentView);
//        make.right.equalTo(self.contentView).offset(-margin);
//        make.size.mas_equalTo(CGSizeMake(10, 10));
//    }];
    
    
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
